/**
 * <br>JAVACC DEMO 1.0<br>
 */
package com.apache.info.service;

import com.apache.database.db.IDao;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

/**
 * description: 系统启动初始化缓存
 *
 * @author Hou DaYu 创建时间：下午02:14:42
 */
public class InfoMetadataListener implements ApplicationListener<ApplicationEvent> {

    public static boolean isStart = false;

    private IDao pubMetadataDao;

    public void onApplicationEvent(ApplicationEvent event) {
        if (isStart)
            return;

//        if (event instanceof ContextClosedEvent) {//当ApplicationContext关闭时触发该事件
//
//        } else if (event instanceof ContextRefreshedEvent || event instanceof EnvironmentChangeEvent) {//当ApplicationContext初始化或者刷新时触发该事件
//            if (event.getTimestamp() > 0) {
//                new Thread(new Runnable() {
//
//                    @Override
//                    public void run() {
//                        pubMetadataDao.initSystemCache();
//                    }
//                }).start();
//            }
//        }
        isStart = true;
    }

    public void setPubMetadataDao(IDao pubMetadataDao) {
        this.pubMetadataDao = pubMetadataDao;
    }
}
